<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">


    <title>
        企业注册</title>


    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <!-- Font Awesome -->
    <!-- Ionicons -->
    <!-- Theme style -->
    <!-- iCheck -->
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link rel="stylesheet" href="__STATIC__/dist/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="__STATIC__/dist/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="__STATIC__/dist/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="__STATIC__/dist/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="__STATIC__/dist/plugins/iCheck/square/blue.css">

    <link rel="stylesheet" type="text/css" href="__STATIC__/my/css/register1.css" >
    <link rel="stylesheet" type="text/css" href="__STATIC__/my/css/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/my/css/bootstrap.min.css">
<!--    <style type="text/css">-->
<!--        .form-control-feedback{-->
<!--            left: 30px;-->
<!--        }-->
<!--    </style>-->
</head>

<body>
<div class="register-box mt-5" id="register-box">
    <div class="register-logo">
    <h1 class="pt-5"><strong><span>农</span>产品</strong>后台管理系统</h1>
    <h6 >新用户注册(公司)</h6>
</div>

<form id="registerForm" method="post">
    <div class="form-group has-feedback">
        <input id="name" name="name" type="text" class="form-control input-box" placeholder="公司名">
        <span class="glyphicon glyphicon-user form-control-feedback" ></span>
    </div>
    <div class="form-group has-feedback">
        <input name="email" type="email" class="form-control input-box" placeholder="Email">
        <span class="glyphicon glyphicon-envelope form-control-feedback" ></span>
    </div>
    <div class="form-group has-feedback">
        <input name="mobile" type=" text" class="form-control input-box" placeholder="电话">
        <span class="glyphicon glyphicon-earphone form-control-feedback" ></span>
    </div>
    <div class="form-group has-feedback">
        <input name="pwd" id="pwd" type="password" class="form-control input-box" placeholder="密码(6-10位字母和数字组合密码)">
        <span class="glyphicon glyphicon-lock form-control-feedback" ></span>
    </div>
    <div class="form-group has-feedback">
        <input type="password" name="checkPwd" id="checkPwd" class="form-control input-box" placeholder="确认密码">
        <span class="glyphicon glyphicon-log-in form-control-feedback"></span>
        <span id="checkPwdMsg" style="color: rgba(168,15,24,0.6)"></span>
    </div>
    <div class="form-group has-feedback">
        <input name="cGoods" type="text" class="form-control input-box" placeholder="企业产品">
        <span class="glyphicon glyphicon-th-list form-control-feedback" ></span>
    </div>
    <div class="form-group has-feedback select-box" >
        <label for="sel3" class="form-label option" >企业类型：</label>
        <select name="cClass" >
            <option value="合资">合资</option>
            <option value="独资">独资</option>
            <option value="国有">国有</option>
            <option value="私营">私营</option>
            <option value="全民所有制">全民所有制</option>
            <option value="集体所有制">集体所有制</option>
            <option value="股份制">股份制</option>
            <option value="有限责任制">有限责任制</option>
        </select>
    </div>
    <div class="form-group has-feedback select-box mt-4" style="text-align: center;">
        <label for="sel3" class="form-label option" >所属地区：</label>
        <select name="rID"  >
            {volist name="regionList" id="item"}
            <option value="{$item.rID}">{$item.name}</option>
            {/volist}
        </select>
    </div>
    <div class=" btn-box row mt-4">
        <div class="col-8">
            <div class="checkbox icheck">
                <label>
                    <input type="checkbox" > 我同意 <a href="#" title="点击获取详细协议内容">协议</a>
                </label>
            </div>
        </div>
        <div class="register col-4">
            <button type="submit" id="btn-sub" class="btn btn-primary btn-block btn-flat">注册</button>
        </div>
    </div>
</form>
<div class="to_login mb-3">
    <a href="{:url('index/index')}" class="text-center">我有账号，现在就去登录</a>
</div>
</div>
<!-- /.form-box -->
<!-- /.register-box -->

<!-- jQuery 2.2.3 -->
<!-- Bootstrap 3.3.6 -->
<!-- iCheck -->
<!-- 引入js依赖 -->
{include file="public/introduce" /}
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });
    });

    /* 表单字段验证 */
    $('#registerForm').bootstrapValidator({
        excluded: [":disabled", ":hidden", ":not(:visible)"], //不验证的情况
        message: '表单校验',
        /**
         * 生效规则（三选一）
         * enabled 字段值有变化就触发验证
         * disabled,submitted 当点击提交时验证并展示错误信息
         */
        live: 'enabled',
        /* button type为submit时无需额外绑定 */
        //验证字段以及规则
        fields: {

            name: {
                trigger: "change",
                validators: {
                    notEmpty: {
                        message: '公司名不能为空'
                    },
                    remote: {
                        type: "post",
                        url: "../index/getName",
                        data: function (validator) {
                            return {name: $('#name').val()}
                        },
                        delay: 800,//延迟发送请求（默认输入一个字符，提交一次，服务器压力太大）
                        message: "已有企业名"
                    }
                }
            },
            email: {
                trigger: "change",
                verbose: false,
                validators: {
                    notEmpty: {
                        message: 'email不能为空'
                    },
                    emailAddress: {
                        message: '邮箱地址格式有误'
                    },
                }
            },
            mobile: {
                trigger: "change",
                validators: {
                    notEmpty: {
                        message: 'mobile不能为空'
                    },
                    regexp: {  //正则验证
                        regexp: /^1\d{10}$/,
                        message: '请输入正确的电话号'
                    }
                }
            },
            pwd: {
                trigger: "change",
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 10,
                        message: "密码长度须在6-10之间"
                    },
                    regexp: {
                        regexp: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]/,
                        message: '密码由字母和数字组成，不能是纯数字或纯英⽂！'
                    }
                },
            },
            checkPwd: {
                validators: {
                    notEmpty: {
                        message: '请再次输入新密码！',
                        equalTo: "#pwd"
                    },
                    identical: {
                        field: 'pwd',
                        message: '两次填写的密码不一致！'
                    }

                }
            },
            cGoods: {
                validators: {
                    notEmpty: {
                        message: '企业产品不能为空'
                    }
                }
            }

        }
    }).on("success.form.bv", function (e) { //验证成功后提交表单
        $.ajax({
            url: "../index/do_register",
            type: "post",
            async: false,
            data: $('#registerForm').serialize(),
            success: function (result) {
                if (result.success) {
                    alert("注册成功！请返回登录界面进行登录！");
                }
            }
        });
    });

</script>
</body>

</html>